<%@ page import="com.opensymphony.xwork2.util.ValueStack" %>
<%@ page import="examinee.ExamineeInfo" %>
<%@ page import="exam.AnswerPaperInfo" %>
<%@ page import="java.util.List" %>
<%@ page import="question.QuestionVar" %>
<%@ page import="utils.TextUtils" %>
<%@ page import="question.QuestionUtils" %>
<%@ page import="exam.TestPaperInfo" %>
<%@ page import="utils.Var" %>
<%@ page import="exam.ExamVar" %>
<%@ page import="account.AccountUtils" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    ValueStack vs = (ValueStack) request.getAttribute("struts.valueStack");
    ExamineeInfo einfo = (ExamineeInfo) vs.findValue("einfo");
    TestPaperInfo tinfo = (TestPaperInfo) vs.findValue("tinfo");
    List<AnswerPaperInfo> alist = (List<AnswerPaperInfo>) vs.findValue("alist");

    boolean isCheat = tinfo.getCheat() == 1;

    boolean isEnd = tinfo.getState() == ExamVar.STATE_END;
    boolean isControlDetail = AccountUtils.hasRight(session, Var.RIGHT_CONTROL_DETAIL);
    boolean isShowAnswer = isEnd || isControlDetail;

    int score = 0;
    for (AnswerPaperInfo info : alist) {
        if (info.getAnswer() != null && info.getAnswer().equals(info.getStandardAnswer())) {
            score += info.getTx() == QuestionVar.TX_MULTI_CHOICE ? 2 : 1;
        }
    }
%>
<h2 class="title info">
    <span>准考证号：</span><%=einfo.getZkzh() == null ? "" : einfo.getZkzh()%>
    <span>姓名：</span><%=einfo.getEname() == null ? "" : einfo.getEname()%>
    <span>分数：</span><%=score%><span id="cheatStr" style="color:red">
    <%
        if(isCheat){
    %>
    <img src='../../skin/default/exclamation.gif'/>作弊
    <%
        }
    %></span>
</h2>
<iframe name="submithidden" style="display:none" id="submithidden"></iframe>
<div class="admin-tablenav" style="float:right; margin-top:-20px;">
    <form target="submithidden" method="post" id="cheatFrom">
        <input name="tid" type="hidden" value="<%=tinfo.getTid()%>"/>
        <button type="button" class="normal" onclick="cheatCtr(this)" cheat="<%=isCheat?"false":"true"%>"><span></span>
            <%=isCheat?"<img src='../../skin/default/wand.gif'/>取消作弊":"<img src='../../skin/default/exclamation.gif'/>作弊"%>
        </button>
        <button type="submit" class="normal" onclick="form.action='print.action'"><span></span>
            <img src="../../skin/default/print.gif"/>打印列表
        </button>
    </form>
</div>

<!--成绩列表-->
<table cellpadding="0" width="100%" cellspacing="0" class="admin-table" style="margin:0 auto;">
    <thead>
    <tr>
        <th width="800"><span class="first"></span>试题内容</th>
        <th style="width:60px">答案</th>
        <th style="width:80px;" class="last">正确答案</th>
    </tr>
    </thead>
    <tbody>
    <tr>
        <td colspan="3" style="padding:0;">
            <div style="height:350px; overflow:hidden;overflow-y:scroll;width:100%">
                <table cellpadding="0" width="98%" class="admin-table" cellspacing="0" style="margin:0;">
                    <tbody id="infolist">
                    <%
                        for (AnswerPaperInfo info : alist) {
                    %>
                    <tr>
                        <td class="first"><%=TextUtils.html(info.getContent())%>
                        </td>
                        <td width="55"><%=info.getAnswer() == null || info.getAnswer().length() == 0 ? "&nbsp;" : QuestionUtils.getAnswer(info.getTx(), info.getAnswer())%>
                        </td>
                        <td width="63" class="last"><%=!isShowAnswer?"&nbsp;":QuestionUtils.getAnswer(info.getTx(), info.getStandardAnswer())%>
                        </td>
                    </tr>
                    <%
                        }
                    %>
                    </tbody>
                </table>
            </div>
        </td>
    </tr>

    </tbody>
</table>